<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>设备转移管理</title>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=201908121454" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/common.js?v=201907231346" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>

    <style>
        .mbox {
            padding: 8px;
        }
        .layui-btn {
            margin-left: 10px;
        }
        .layui-btn .layui-icon {
            margin-right: 0px;
        }

        .layui-card-body {
            display: flex;
            padding: 0px;
        }
        .bg{
            background-color: #F2F2F2;
        }
        .layui-rt {
            width: 100%;
        }
        .layui-form-select .layui-input{
            height: 32px;
        }
        .layui-tab-title{
            height: 32px;
        }

        .layui-tab-title li{
            height: 33px;
            line-height: 33px;
        }
        .layui-tab layui-tab-card{
            margin-top: -4px;
        }
        .layui-tab-card>.layui-tab-title .layui-this:after {
            border-width: 0px;
        }
        .layui-table{
            margin-top: -2px !important;
        }
        .layui-table-view .layui-table td, .layui-table-view .layui-table th{
            padding: 2px 0;
        }
        #infoId td{
            padding: 5px 2px;
        }
        .tablecolor{
            background-color:#f2f2f2;
        }
        .layui-table{
            width:100%!important;
        }
    </style>
</head>
<body>
<div class="mbox">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-rt">
                <div class="layui-tab layui-tab-card" lay-filter="tabtoggle">
                    <ul class="layui-tab-title">
                        <li class="layui-this">待批申请</li>
                        <li>已准申请</li>
                        <li>未准申请</li>
                    </ul>
                    <%--页签下面内容--%>
                    <div class="layui-tab-content" style="height:100%;padding: 0 10px 10px 10px">
                        <div class="layui-tab-item layui-show">
                            <table class="layui-table" lay-skin="line" id="Settlement" lay-size="sm" lay-filter="SettlementFilter"></table>
                            <div class="layui-tab layui-tab-card" lay-filter="bottomTab" style="position: relative;z-index: 0;margin-top: 15px">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">转移设备明细</li>
                                </ul>
                                <div class="layui-tab-content" style="padding: 0 10px">
                                    <div class="layui-tab-item layui-show">
                                        <table id="transferDetail" lay-filter="transferFilter" lay-size="sm"> </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <table class="layui-table" lay-skin="line" id="accurateTable" lay-size="sm" lay-filter="accurateTableFilter"></table>
                            <div class="layui-tab layui-tab-card" lay-filter="bottomTab" style="position: relative;z-index: 0;margin-top: 15px">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">转移设备明细</li>
                                </ul>
                                <div class="layui-tab-content" style="padding: 0 10px">
                                    <div class="layui-tab-item layui-show">
                                        <table id="accurateDetail" lay-filter="accurateFilter" lay-size="sm"> </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <table class="layui-table" lay-skin="line" id="notexactlyTable" lay-size="sm" lay-filter="notexactlyTableFilter"></table>
                            <div class="layui-tab layui-tab-card" lay-filter="bottomTab" style="position: relative;z-index: 0;margin-top: 15px">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">转移设备明细</li>
                                </ul>
                                <div class="layui-tab-content" style="padding: 0 10px">
                                    <div class="layui-tab-item layui-show">
                                        <table id="notexactlyDetail" lay-filter="notexactlyFilter" lay-size="sm"> </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%--报废申请新增/删除撤销/查询字段--%>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="approval" style="width: 70px">批准</button>
        <button class="layui-btn layui-btn-sm" lay-event="disApproval" style="width: 100px">不批准</button>
    </div>
    <div class="demoTable" style="position:absolute;right: 8%;top: 10px;width: 600px;height: 30px">
        <label style="float: left;width: 60px;">查询字段</label>
        <div class="layui-input-inline" style="float:left;">
            <select name="modules" lay-verify="required" lay-filter="serachInfo"lay-search="" placeholder="请选择" style="height: 10px">
                <option value="0">请选择查询字段</option>
                <option value="APPLICANT">报废申请人</option>
                <option value="SCRAP_REASON">报废原因</option>
                <option value="WORKFLOW_NO">流水号</option>
            </select>
        </div>
        <div style="float: left">
            <div class="layui-inline">
                <input class="layui-input" name="searchtext"  autocomplete="off" style="height: 32px;margin-left: 6px;">
            </div>
            <button class="layui-btn" data-type="reload"   lay-event="searchCust" style="height:30px;line-height: 30px; ">搜索</button>
        </div>
    </div>
</script>
<%--查询字段（已准）--%>
<script type="text/html" id="accurate">
    <div class="demoTablea" style="position:absolute;right: 8%;top: 10px;width: 600px;height: 30px">
        <label style="float: left;width: 60px;">查询字段</label>
        <div class="layui-input-inline" style="float:left;">
            <select name="modules" lay-verify="required" lay-filter="serachInfo"  placeholder="请选择" lay-search="" style="height: 10px">
                <option value="0">请选择查询字段</option>
                <option value="APPLICANT">报废申请人</option>
                <option value="SCRAP_REASON">报废原因</option>
                <option value="WORKFLOW_NO">流水号</option>
            </select>
        </div>
        <div style="float: left">
            <div class="layui-inline">
                <input class="layui-input" name="searchtexta" autocomplete="off" style="height: 32px;margin-left: 6px;">
            </div>
            <button class="layui-btn" data-type="reload"  lay-event="searchCusta" style="height:30px;line-height: 30px;">搜索</button>
        </div>
    </div>
</script>
<%--查询字段（未批）--%>
<script type="text/html" id="notexactly">
    <div class="demoTableb" style="position:absolute;right: 8%;top: 10px;width: 600px;height: 30px">
        <label style="float: left;width: 60px;">查询字段</label>
        <div class="layui-input-inline" style="float:left;">
            <select name="modules" lay-verify="required" lay-filter="serachInfo"  placeholder="请选择" lay-search="" style="height: 10px">
                <option value="0">请选择查询字段</option>
                <option value="APPLICANT">报废申请人</option>
                <option value="SCRAP_REASON">报废原因</option>
                <option value="WORKFLOW_NO">流水号</option>
            </select>
        </div>
        <div style="float: left">
            <div class="layui-inline">
                <input class="layui-input" name="searchtextb" autocomplete="off" style="height: 32px;margin-left: 6px;">
            </div>
            <button class="layui-btn" data-type="reload"  lay-event="searchCustb" style="height:30px;line-height: 30px;">搜索</button>
        </div>
    </div>
</script>


<%--借还申请上头部--%>
<script type="text/html" id="barOperation">
    <a class="layui-btn layui-btn-xs" lay-event="approval" id="sub">批准</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="disApproval" id="edit">不批准</a>
</script>


<script type="text/javascript">
    var settlementTable,
        accurateTable,
        notexactlyTable,
        acceptTable,
        transferDetail;
    var scraplogId;
    var topindexPage=0;

    var col = [[
        , {field: 'equipName', title: '设备名称'}
        , {field: 'equipNo', title: '固定资产编号'}
        , {field: 'factoryNo', title: '出厂编号'}
        , {field: 'equipTypeName', title: '设备类型'}
        , {field: 'equipStatusName', title: '资产状态'}
        , {field: 'modelNo', title: '型号'}
        , {field: 'spec', title: '规格'}
        //, {field: 'scrapReason', title: '报废原因'}
        //, {field: 'memo', title: '备注'}
    ]];
    layui.use(['table', 'layer','laydate', 'form', 'element'], function () {
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;
        var element = layui.element;
        var laydate = layui.laydate;

        //报废申请表格实例
        settlementTable = table.render({
            elem: '#Settlement'
            , page: true //开启分页
            , url: '/equipmentScrapping/showScraplogWait'//数据接口
            , toolbar: '#toolbar'
            , cols: [[ //标题栏
                {type: 'checkbox'}
                ,{field: 'scraplogId', title: '申请编号'}
                , {field: 'applicant', title: '报废申请人'}
                , {field: 'deptName', title: '报废申请部门'}
                , {field: 'applicantTime', title: '报废申请时间',templet: function(d) {
                        return format(d.applicantTime)
                    }}
                , {field: 'workflowNo', title: '流水号'}
                , {field: 'scrapReason', title: '报废原因'}
                , {field: 'memo', title: '备注'}
                , {width: 200,title: '操作', align: 'center', toolbar: '#barOperation'}
            ]],
            done: function (res) {
                if (res.data.length > 0) {
                    var scraplogId = res.data[0].scraplogId;
                    equipTable("#transferDetail", scraplogId, "#toolbars", col);
                } else {
                    cequipTable("#transferDetail", "#", col);
                }
            }
        });

        //监听第一实例表格行单击事件
        table.on('row(SettlementFilter)', function (obj) {
            var tr = obj.tr //得到当前行元素对象
            var data = obj.data //得到当前行数据
            scraplogId = data.scraplogId
            //选中行变颜色方法
            var index = $(this).attr('data-index');
            var tr = $(this).parent().children(tr);
            $(this).addClass("bg");
            for (var i = 0; i < tr.length; i++) {
                if (index != i) {
                    tr.eq(i).removeClass("bg");
                }
            }
            equipTable("#transferDetail", data.scraplogId, "#", col)
        });
        // 待批申请头部事件
        table.on('toolbar(SettlementFilter)', function (obj) {
            var layEvent = obj.event;
            switch (layEvent) {
                case 'approval':
                    var data = table.checkStatus('Settlement').data;
                    if (data.length == 0 || data.length < 0) {
                        layer.msg("请选择一条或者多条进行提交。");
                        return false;
                    } else if (data.length > 0) {
                        var data = layui.table.checkStatus('Settlement').data;
                        var ids = "";
                        for (var i = 0; i < data.length; i++) {
                            ids += data[i].scraplogId + ",";
                        }
                        $.ajax({
                            type: "post",
                            url: "/equipmentScrappingManagement/ratify",
                            dataType: "json",
                            data: {
                                ids: ids
                            },
                            success: function (res) {
                                if (res.code == 0) {
                                    layer.msg(res.msg);
                                    settlementTable.reload();
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                    }
                    break;
                case 'disApproval':
                    var data = table.checkStatus('Settlement').data;
                    var ids = "";
                    for (var i = 0; i < data.length; i++) {
                        ids += data[i].scraplogId + ",";
                    }
                    if (data.length == 0 || data.length < 0) {
                        layer.msg("请选择一条或者多条进行提交。");
                        return false;
                    } else if (data.length > 0) {
                        $.ajax({
                            type: "post",
                            url: "/equipmentScrappingManagement/nonPlacet",
                            dataType: "json",
                            data: {
                                ids: ids
                            },
                            success: function (res) {
                                if (res.code == 0) {
                                    layer.msg(res.msg);
                                    settlementTable.reload();
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                    }
                    break;
                case 'searchCust':
                    var inptext=$(".demoTable input[name='searchtext']").val();
                    var seletext=$(".demoTable").find("dl dd.layui-this").attr("lay-value");
                    console.log(seletext)
                    if((inptext == "")&&(seletext==undefined)){
                        layer.msg("请输入需要搜索的条件");
                        return false;
                    }else if((inptext=="")&&(seletext!=undefined)){
                        layer.msg("请输入需要查询的条件");
                        return false;
                    }else if((inptext!="")&&(seletext==undefined)){
                        layer.msg("请选择查询的字段");
                        return false;
                    }else{
                        var datas={
                            inptext:inptext,
                            column:seletext
                        }
                        searchCusInfo(datas)
                    }
                    break;
            }
        });
        // 转移申请行内操作事件
        table.on('tool(SettlementFilter)', function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if (layEvent === 'approval') {
                var ids = data.scraplogId + ","
                $.ajax({
                    type: "post",
                    url: "/equipmentScrappingManagement/ratify",
                    dataType: "json",
                    data: {
                        ids: ids
                    },
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg);
                            settlementTable.reload();
                        } else {
                            layer.msg(res.msg);
                        }
                    }
                })
            } else if (layEvent === 'disApproval') {;
                var ids = data.scraplogId + ",";
                $.ajax({
                    type: "post",
                    url: "/equipmentScrappingManagement/nonPlacet",
                    dataType: "json",
                    data: {
                        ids: ids
                    },
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg);
                            settlementTable.reload();
                        } else {
                            layer.msg(res.msg);
                        }
                    }
                })
            }
        });
        //已准申请表格实例
        accurateTable = table.render({
            elem: '#accurateTable'
            , url: ''
            , data: []
            , page: true //开启分页
            , toolbar: '#accurate'
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            , cols: [[ //标题栏
                {field: 'scraplogId', title: '申请编号'}
                , {field: 'applicant', title: '报废申请人'}
                , {field: 'deptName', title: '报废申请部门'}
                , {field: 'applicantTime', title: '报废申请时间',templet: function(d) {
                        return format(d.applicantTime)
                    }}
                , {field: 'approver', title: '审批人'}
                , {field: 'approverTime', title: '审批时间'}
                , {field: 'workflowNo', title: '流水号'}
                , {field: 'scrapReason', title: '报废原因'}
                , {field: 'memo', title: '备注'}
            ]],
            done: function (res) {
                if(res.data.length >0){
                    var scraplogId = res.data[0].scraplogId;
                    equipTable("#accurateDetail",scraplogId,"#toolbars",col);
                }else{
                    cequipTable("#accurateDetail","#toolbars",col);
                }
            }
        });

        //监听第三实例表格行单击事件
        table.on('row(accurateTableFilter)', function (obj) {
            var tr = obj.tr //得到当前行元素对象
            var data = obj.data //得到当前行数据

            //选中行变颜色方法
            var index = $(this).attr('data-index');
            var tr = $(this).parent().children(tr);
            $(this).addClass("bg");
            for (var i = 0; i < tr.length; i++) {
                if (index != i) {
                    tr.eq(i).removeClass("bg");
                }
            }
            equipTable("#accurateDetail", data.scraplogId, "#", col);
        });

        //未准表格实例
        notexactlyTable = table.render({
            elem: '#notexactlyTable'
            , url: ''
            , data: []
            , toolbar: '#notexactly'
            , page: true //开启分页
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            , cols: [[ //标题栏
                {field: 'scraplogId', title: '申请编号'}
                , {field: 'applicant', title: '报废申请人'}
                , {field: 'deptName', title: '报废申请部门'}
                , {field: 'applicantTime', title: '报废申请时间',templet: function(d) {
                        return format(d.applicantTime)
                    }}
                , {field: 'approver', title: '审批人'}
                , {field: 'approverTime', title: '审批时间'}
                , {field: 'workflowNo', title: '流水号'}
                , {field: 'scrapReason', title: '报废原因'}
                , {field: 'memo', title: '备注'}
            ]],
            done: function (res) {
                if(res.data.length >0){
                    var scraplogId = res.data[0].scraplogId;
                    equipTable("#notexactlyDetail",scraplogId,"#toolbars",col);
                }else{
                    cequipTable("#notexactlyDetail","#toolbars",col);
                }
            }
        });

        //监听第四实例表格行单击事件
        table.on('row(notexactlyTableFilter)', function (obj) {
            var tr = obj.tr //得到当前行元素对象
            var data = obj.data //得到当前行数据

            //选中行变颜色方法
            var index = $(this).attr('data-index');
            var tr = $(this).parent().children(tr);
            $(this).addClass("bg");
            for (var i = 0; i < tr.length; i++) {
                if (index != i) {
                    tr.eq(i).removeClass("bg");
                }
            }
            equipTable("#notexactlyDetail", data.scraplogId, "#", col)

        });
        //顶部页签切换事件
        element.on('tab(tabtoggle)', function (data) {
            var index = data.index;
            topindexPage=data.index;
            switch (index) {
                case 0:
                    settlementTable.reload({
                        url:'/equipmentScrapping/showScraplogWait'
                    })
                    break;
                case 1:
                    accurateTable.reload({
                        url:'/equipmentScrapping/showScraplogYes'
                    })
                    break;
                case 2:
                    notexactlyTable.reload({
                        url:'/equipmentScrapping/showScraplogNo'
                    })
                    break;
            }
        });
        // 已批头部事件
        table.on('toolbar(accurateTableFilter)', function (obj) {
            var layEvent = obj.event;
            switch (layEvent) {
                case 'searchCusta':
                    var inptext=$(".demoTablea input[name='searchtexta']").val();
                    var seletext=$(".demoTablea").find("dl dd.layui-this").attr("lay-value");
                    console.log(seletext)
                    if((inptext == "")&&(seletext==undefined)){
                        layer.msg("请输入需要搜索的条件");
                        return false;
                    }else if((inptext=="")&&(seletext!=undefined)){
                        layer.msg("请输入需要查询的条件");
                        return false;
                    }else if((inptext!="")&&(seletext==undefined)){
                        layer.msg("请选择查询的字段");
                        return false;
                    }else{
                        var datas={
                            inptext:inptext,
                            column:seletext
                        }
                        searchCusInfo(datas)
                    }
                    break;
            }
        });
        // 未准表头部事件
        table.on('toolbar(notexactlyTableFilter)', function (obj) {
            var layEvent = obj.event;
            switch (layEvent) {
                case 'searchCustb':
                    var inptext=$(".demoTableb input[name='searchtextb']").val();
                    var seletext=$(".demoTableb").find("dl dd.layui-this").attr("lay-value");
                    console.log(seletext)
                    if((inptext == "")&&(seletext==undefined)){
                        layer.msg("请输入需要搜索的条件");
                        return false;
                    }else if((inptext=="")&&(seletext!=undefined)){
                        layer.msg("请输入需要查询的条件");
                        return false;
                    }else if((inptext!="")&&(seletext==undefined)){
                        layer.msg("请选择查询的字段");
                        return false;
                    }else{
                        var datas={
                            inptext:inptext,
                            column:seletext
                        }
                        searchCusInfo(datas)
                    }
                    break;
            }
        });
    });


    //模糊查询
    function searchCusInfo(data) {
        var parm={}
        var toolb;
        var clo;
        var tableName;

        // if(data.column=="RETURN_STATUS"){
        //     if(data.inptext=="部分归还"){
        //         data.inptext=1;
        //     }if(data.inptext=="全部归还"){
        //         data.inptext=2
        //     }if(data.inptext=="未归还"){
        //         data.inptext=0;
        //     }
        // }
        if (topindexPage == 0) {
            parm = {
                column: data.column,
                inptext: data.inptext
            }
            $.ajax({
                type: 'post'
                ,url:'/equipmentScrapping/showScraplogWait'
                , data: parm
                , dataType: 'json',
                success: function (res) {
                    var datas = res.data;
                    layui.table.render({
                        elem: '#Settlement'
                        , page: true //开启分页
                        , url: ''//数据接口
                        ,data:datas
                        , toolbar: '#toolbar'
                        , cols: [[ //标题栏
                            {type: 'checkbox'}
                            ,{field: 'scraplogId', title: '申请编号'}
                            , {field: 'applicant', title: '报废申请人'}
                            , {field: 'deptName', title: '报废申请部门'}
                            , {field: 'applicantTime', title: '报废申请时间',templet: function(d) {
                                    return format(d.applicantTime)
                                }}
                            , {field: 'workflowNo', title: '流水号'}
                            , {field: 'scrapReason', title: '报废原因'}
                            , {field: 'memo', title: '备注'}
                            , {width: 200,title: '操作', align: 'center', toolbar: '#barOperation'}
                        ]],
                        done: function (res) {
                            if (res.data.length > 0) {
                                var scraplogId = res.data[0].scraplogId;
                                equipTable("#transferDetail", scraplogId, "#toolbars", col);
                            } else {
                                cequipTable("#transferDetail", "#", col);
                            }
                            $(".demoTable input[name='searchtext']").val(data.inptext);
                            $(".demoTable").find("select[name='modules']").each(function () {
                                // this代表的是<option></option>，对option再进行遍历
                                $(this).children("option").each(function () {
                                    // 判断需要对那个选项进行回显
                                    if (this.value == data.column) {
                                        // 进行回显
                                        $(this).attr("selected", "selected");
                                    }
                                });
                            })
                            layui.form.render('select');
                        }
                    })
                }

            })
        } else if (topindexPage == 1) {
            parm = {
                column: data.column,
                inptext: data.inptext
            }

            $.ajax({
                type: 'post'
                ,url:'/equipmentScrapping/showScraplogYes'
                , data: parm
                , dataType: 'json',
                success: function (res) {
                    var datas = res.data;

                    layui.table.render({
                        elem: '#accurateTable'
                        , url: ''
                        , data: datas
                        , page: true //开启分页
                        , toolbar: '#accurate'
                        , limit: 5 //每页默认显示的数量
                        , limits: [5, 10, 15, 20, 25, 30]
                        , cols: [[ //标题栏
                            {field: 'scraplogId', title: '申请编号'}
                            , {field: 'applicant', title: '报废申请人'}
                            , {field: 'deptName', title: '报废申请部门'}
                            , {field: 'applicantTime', title: '报废申请时间',templet: function(d) {
                                    return format(d.applicantTime)
                                }}
                            , {field: 'approver', title: '审批人'}
                            , {field: 'approverTime', title: '审批时间'}
                            , {field: 'workflowNo', title: '流水号'}
                            , {field: 'scrapReason', title: '报废原因'}
                            , {field: 'memo', title: '备注'}
                        ]],
                        done: function (res) {
                            if(res.data.length >0){
                                var scraplogId = res.data[0].scraplogId;
                                equipTable("#accurateDetail",scraplogId,"#toolbars",col);
                            }else{
                                cequipTable("#accurateDetail","#toolbars",col);
                            }
                            $(".demoTablea input[name='searchtexta']").val(data.inptext);
                            $(".demoTablea").find("select[name='modules']").each(function () {
                                // this代表的是<option></option>，对option再进行遍历
                                $(this).children("option").each(function () {
                                    // 判断需要对那个选项进行回显
                                    if (this.value == data.column) {
                                        // 进行回显
                                        $(this).attr("selected", "selected");
                                    }
                                });
                            })
                            layui.form.render('select');
                        }
                    });
                }
            })
        } else if (topindexPage == 2) {
            parm = {
                column: data.column,
                inptext: data.inptext
            }
            $.ajax({
                type: 'post'
                , url:'/equipmentScrapping/showScraplogNo'
                , data: parm
                , dataType: 'json',
                success: function (res) {
                    var datas = res.data;
                    layui.table.render({
                        elem: '#notexactlyTable'
                        , url: ''
                        , data: datas
                        , toolbar: '#notexactly'
                        , page: true //开启分页
                        , limit: 5 //每页默认显示的数量
                        , limits: [5, 10, 15, 20, 25, 30]
                        , cols: [[ //标题栏
                            {field: 'scraplogId', title: '申请编号'}
                            , {field: 'applicant', title: '报废申请人'}
                            , {field: 'deptName', title: '报废申请部门'}
                            , {field: 'applicantTime', title: '报废申请时间',templet: function(d) {
                                    return format(d.applicantTime)
                                }}
                            , {field: 'approver', title: '审批人'}
                            , {field: 'approverTime', title: '审批时间'}
                            , {field: 'workflowNo', title: '流水号'}
                            , {field: 'scrapReason', title: '报废原因'}
                            , {field: 'memo', title: '备注'}
                        ]],
                        done: function (res) {
                            if(res.data.length >0){
                                var scraplogId = res.data[0].scraplogId;
                                equipTable("#notexactlyDetail",scraplogId,"#toolbars",col);
                            }else{
                                cequipTable("#notexactlyDetail","#toolbars",col);
                            }
                            // $("#" + searchColum + "").val($("#" + searchColum + "").val())
                            // $("#colum").find('option[value="' + searchColum + '"]').prop('selected', 'selected');
                            $(".demoTableb input[name='searchtextb']").val(data.inptext);
                            $(".demoTableb").find("select[name='modules']").each(function () {
                                // this代表的是<option></option>，对option再进行遍历
                                $(this).children("option").each(function () {
                                    // 判断需要对那个选项进行回显
                                    if (this.value == data.column) {
                                        // 进行回显
                                        $(this).attr("selected", "selected");
                                    }
                                });
                            })
                            layui.form.render('select');
                        }
                    });
                }
            })
        }
    }
    //将毫秒数转为yyyy-MM-dd格式时间
    function format(t) {
        if(t) return new Date(t).Format("yyyy-MM-dd");
        else return ''
    }
    //设备转移明细表格实例
    function equipTable(gid,logid,tid,col) {
        layui.table.render({
            elem: gid
            ,data:[]
            , url: '/equipmentScrapping/showScraplist?scraplogId='+logid
            ,toolbar:tid
            , page: true //开启分页
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            , cols: col
        });
    }
    function cequipTable(gid,tid,col) {
        layui.table.render({
            elem: gid
            ,data:[]
            ,toolbar:tid
            , page: true //开启分页
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            , cols: col
        });
    }
    // 批准选人操作
    function Xrtransfer(res){
        var newuserId = res.userId;
        var newuserName = res.userName;
        var data = layui.table.checkStatus('Settlement').data;
        var logIds = "";
        var approvalStatus = "2";
        for (var i = 0; i < data.length; i++) {
            logIds += data[i].ownerlogId + ",";
        }
        $.ajax({
            type: "post",
            url: "/equipTransfer/updStatus",
            dataType: "json",
            data: {
                logIds: logIds,
                recUser:newuserId,
                approvalStatus:approvalStatus
            },
            success: function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg);
                    settlementTable.reload();
                } else {
                    layer.msg(res.msg);
                }
            }
        })
    }
    // 批准选人行内操作
    function Xrhntransfer(res){
        var newuserId = res.userId;
        var newuserName = res.userName;
        var logIds = ownerlogId + ",";
        var approvalStatus = "2";
        $.ajax({
            type: "post",
            url: "/equipTransfer/updStatus",
            dataType: "json",
            data: {
                logIds: logIds,
                recUser:newuserId,
                approvalStatus:approvalStatus
            },
            success: function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg);
                    settlementTable.reload();
                } else {
                    layer.msg(res.msg);
                }
            }
        })
    }
</script>
</body>
</html>

